/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication6.PBO1.src.pbo1;

import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author admin
 */
public class TesPegawai {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int pilih,i=0;
        String jawab;
        Pegawai[] peg=new Pegawai[10];
        String nip,nama;
        int jumAnak;
        double jamLembur,gajiPokok;
        do
        {
            System.out.println("Pilih data pegawai yang akan dimasukkan :");
            System.out.println("1. Manajer");
            System.out.println("2. Marketing");
            System.out.println("3. Administrasi");
            pilih=sc.nextInt();
            System.out.print("\nMasukkan kode peg ");
            nip = sc.next();
            System.out.print("\nMasukkan nama peg ");
            nama=sc.next();
            System.out.print("\nMasukkan gaji pokok ");
            gajiPokok=sc.nextDouble();
            System.out.print("\nMasukkan jam lembur");
            jamLembur=sc.nextDouble();
            System.out.print("\nMasukkan jumlah anak ");
            jumAnak=sc.nextInt();
            if (pilih== 1)
            {
                peg[i]=new Manajer();
                System.out.print("\nMasukkan tunjangan jabatan ");
                ((Manajer)peg[i]).setTunjanganJabatan(sc.nextDouble());
                
            }else if (pilih==2)
            {
                peg[i]=new Marketing();
                System.out.print("\nMasukkan jumlah order ");
                ((Marketing)peg[i]).setJumlahOrder(sc.nextDouble());
            }else if (pilih==3)
            {
                peg[i]=new Administrasi();
                System.out.print("\nMasukkan jumlah hari ");
                ((Administrasi)peg[i]).setJumlahHari(sc.nextInt());
            }else{
                System.out.println("Anda salah memasukkan pilihan");}

            peg[i].setNip(nip);
            peg[i].setNama(nama);
            peg[i].setJumlah_anak(jumAnak);
            peg[i].setJam_lembur(jamLembur);
            peg[i].setGaji_pokok(gajiPokok);

            System.out.print("Apakah akan memasukkan data lagi ?");
            jawab=sc.next();
            i++;
        }while (jawab.equals("y") || jawab.equals("Y"));

        System.out.println("NIP     Nama     Jenis   Tunjangan   Lembur   Tambahan   Total");
        for(int j=0;j<i;j++)
        {
            System.out.print(String.format("%-4s", peg[j].getNip()));
            System.out.print(String.format("%-13s", peg[j].getNama()));
            System.out.print(String.format("%-12s", peg[j].getClass().getSimpleName()));
            System.out.print(String.format("%-10s",peg[j].tunjanganKeluarga() ));
            System.out.print(String.format("%-10s", peg[j].gajiLembur()));

        if (peg[j] instanceof Manajer)
        {
           System.out.print(String.format("%-10s", ((Manajer)peg[j]).getTunjanganJabatan()));
        }
        else if (peg[j] instanceof Marketing)
        {
        System.out.print(String.format("%-10s", ((Marketing)peg[j]).hitungBonus()));

        }
        else if (peg[j] instanceof Administrasi)
        { System.out.print(String.format("%-10s", ((Administrasi)peg[j]).hitungTunjTransport()));
        }
        System.out.print(String.format("%-10s", peg[j].gajiTotal()));

        System.out.println("");
        }
        
        
        
    }
}
